package com.stylefeng.guns.modular.system.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.common.persistence.dao.DotMapper;
import com.stylefeng.guns.common.persistence.model.Dot;
import com.stylefeng.guns.common.persistence.model.Push;
import com.stylefeng.guns.common.persistence.dao.PushMapper;
import com.stylefeng.guns.modular.system.service.IPushService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author stylefeng123
 * @since 2018-01-16
 */
@Service
public class PushServiceImpl extends ServiceImpl<PushMapper, Push> implements IPushService {
    @Resource
    DotMapper dotMapper;
    @Resource
    PushMapper pushMapper;
    @Override
    public List<Dot> getUndistriDots(Integer deptId) {
        Wrapper<Dot> wrapper = new EntityWrapper<>();
        wrapper = wrapper.where("deptid={0}", deptId).andNew("id not in (select dot_id from sys_push where deptid={0})",deptId);
        List<Dot> list=dotMapper.selectList(wrapper);
        return list;
    }

    @Override
    public List<Map<String, Object>> list(Page<Map<String, Object>> page, Map m) {
        return pushMapper.selectPushList(page,m);
    }
}
